import Mock from 'mockjs'
import {
	getToken
} from '@/utils/auth'
const tokens = {
	admin: {
		token: 'admin-token'
	},
	editor: {
		token: 'editor-token'
	}
}


export default [{
		url: '/captchaImage',
		type: 'get',
		response: config => {
			const captchaImage = {
				'msg': '操作成功',
				// 'img': '/9j/4AAQSkZJRgABAgAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCAA8AKADASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwDtrW1ga1hZoIySikkoOeKsCztv+feL/vgU2z/484P+ua/yqyKiMY8q0IjGPKtCIWdr/wA+0P8A3wKeLK1/59of+/YqU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YvCFxZ6jotrfWhBimQMPb1B9wcj8Kq6jozNPvQd60PDumQ6XE8dvCsKu5kZV4G49Tjt07VvVxMKtCNNwSlHquq8+7XRiUbO50ajinimr0p4rjKHCqur/8gS//AOvaT/0E1bFVdX/5Al//ANe0n/oJqZfCyZfCzkrL/jyt/wDrmv8AKrIrmYtauYokjVIiEUKMg9vxqT+37r/nnD/3yf8AGso1o2RnGrGyOlFOFcz/AMJDd/8APOD/AL5P+NL/AMJFd/8APOD/AL5P+NV7aI/bROn2g9aY1rGxyVFc5/wkl5/zyg/75P8AjS/8JLef88oP++T/AI0e2iHtonURRKg4FTAVyX/CT3v/ADyt/wDvlv8AGl/4Si9/55W//fLf40e2iHtonXgU7bkVx/8AwlV9/wA8rf8A75b/ABpf+Ervv+eVt/3y3+NHtoh7aJ1ZtUZs7RViOMIMAVxv/CW3/wDzxtv++W/xpf8AhL9Q/wCeNt/3y3/xVHtoh7aJ2wp4FcP/AMJhqH/PG1/75b/4ql/4TLUf+eNr/wB8t/8AFUe2iHtonbmJW6inJEF6CuH/AOEz1H/nja/98N/8VS/8JrqX/PC0/wC+G/8AiqPbRD20TvQKeK4D/hNtS/54Wn/fDf8AxVL/AMJxqf8AzwtP++G/+Ko9tEPbRPQRVXV/+QHqH/XtJ/6Ca4r/AITnU/8Anhaf98N/8VUdz4z1G6tZrd4bUJKjIxVWyARjj5qmVaNmKVWNmf/Z',
				'code': '200',
				'uuid': 'ae9a15860c1c49258d83aba42ee15394',
				'img': Mock.Random.dataImage('50x20', Mock.mock({
					'regexp': /\w{4}/
				}).regexp)
			}
			return {
				captchaImage
			}
		}
	},
	// user login
	{
		url: '/login',
		type: 'post',
		response: config => {
			const {
				username
			} = config.body
			const token = tokens[username]
			// mock error
			if (!token) {
				return {
					code: 60204,
					message: 'Account and password are incorrect.'
				}
			}
			return {
				code: 200,
				token: token.token
			}
		}
	},

	// get user info
	{
		url: '/getInfo',
		type: 'get',
		response: config => {
			// const token = getToken()
			// const info = users[token]
			// console.log(token)
			// // mock error
			// if (!info) {
			// 	return {
			// 		code: 50008,
			// 		message: 'Login failed, unable to get user details.'
			// 	}
			// }

			return {
				"msg": "操作成功",
				"code": 200,
				"permissions": [
					"*:*:*"
				],
				"roles": [
					"admin"
				],
				"user": {
					"searchValue": null,
					"createBy": "admin",
					"createTime": "2021-03-03 14:22:33",
					"updateBy": null,
					"updateTime": null,
					"remark": "管理员",
					"params": {},
					"userId": 1,
					"deptId": 103,
					"userName": "admin",
					"nickName": "若依",
					"email": "ry@163.com",
					"phonenumber": "15888888888",
					"sex": "1",
					"avatar": "",
					"salt": null,
					"status": "0",
					"delFlag": "0",
					"loginIp": "127.0.0.1",
					"loginDate": "2021-03-03T14:22:33.000+0800",
					"dept": {
						"searchValue": null,
						"createBy": null,
						"createTime": null,
						"updateBy": null,
						"updateTime": null,
						"remark": null,
						"params": {},
						"deptId": 103,
						"parentId": 101,
						"ancestors": null,
						"deptName": "研发部门",
						"orderNum": "1",
						"leader": "若依",
						"phone": null,
						"email": null,
						"status": "0",
						"delFlag": null,
						"parentName": null,
						"children": []
					},
					"roles": [{
						"searchValue": null,
						"createBy": null,
						"createTime": null,
						"updateBy": null,
						"updateTime": null,
						"remark": null,
						"params": {},
						"roleId": 1,
						"roleName": "超级管理员",
						"roleKey": "admin",
						"roleSort": "1",
						"dataScope": "1",
						"menuCheckStrictly": false,
						"deptCheckStrictly": false,
						"status": "0",
						"delFlag": null,
						"flag": false,
						"menuIds": null,
						"deptIds": null,
						"admin": true
					}],
					"roleIds": null,
					"postIds": null,
					"admin": true
				}
			}
		}
	},

	// user logout
	{
		url: '/logout',
		type: 'post',
		response: _ => {
			return {
				code: 200,
				data: 'success'
			}
		}
	}
]
